class Solution {
public:
    int findSubstringInWraproundString(string s) {
        int n = s.size();
        vector<int>dp(n,1);
        for(int i=1;i<n;i++)
        {
            if(s[i]-1 == s[i-1] || (s[i-1]=='z' && s[i]=='a'))
            {
                dp[i] += dp[i-1];//可以连在一起
            }
        }
        int hash[26]={0};
        for(int i=0;i<n;i++)
        {
            hash[s[i]-'a'] = max(hash[s[i]-'a'],dp[i]);
        }
        int sum = 0;
        for(auto& e :hash) sum+=e;
        return sum;
    }
};